# base image
FROM docker.nju.edu.cn/python:3.10-slim-bookworm AS base

LABEL maintainer="shanyou@htyunwang.com"

# install packages
FROM base as packages

COPY requirements.txt /requirements.txt
RUN pip install --prefix=/pkg -r requirements.txt -i "https://pypi.tuna.tsinghua.edu.cn/simple"


# production stage
FROM base AS production
ENV TZ Asia/Shanghai 

RUN cp /etc/apt/sources.list.d/debian.sources /etc/apt/sources.list.d/debian.sources.bak
RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources \
&& sed -i 's/security.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources

WORKDIR /app

COPY --from=packages /pkg /usr/local

RUN apt update \
&& apt install -y apt-transport-https ca-certificates

RUN playwright install --with-deps
COPY . /app

EXPOSE 8080

# ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]
